import tables, strutils

let AposChar = {'\''}
let SepChars = AllChars - Letters - Digits - AposChar

proc countWords*(input: string): CountTable[string] = 
  # manually deal
  for x in split(input, SepChars):
    var key = x.toLower
    key.removePrefix(AposChar)
    key.removeSuffix(AposChar)
    if key.len > 0:
      # uncomment following line to debug
      # echo key
      result.inc(key)

  # replace with a regex, proc splitWhiteSpace deals with the tailing spaces.
  # input.toLower.replace(re"'?[^A-Za-z0-9']+'?|'$", " ").splitWhiteSpace.toCountTable
